package com.springCrud.simpleCrud.anttask;

import org.apache.commons.lang.StringUtils;

public class MySqlDMLConverter extends AbstractDMLConverter {

	public MySqlDMLConverter(String tableName, String[] columnName, String[] columnValue) {
		super(tableName, columnName, columnValue);
	}

	@Override
	protected String escapeColumnValue(String column, String value) {
		if(StringUtils.isEmpty(value)) return "NULL";
		
		// bit column
		if(StringUtils.equalsIgnoreCase("status", column)) return value;
		if(StringUtils.equalsIgnoreCase("joinAbsen", column)) return value;
		
		value = value.replaceAll("[']", "''");
		//value = value.replaceAll("[&]", "' + char(38) +'");
		value = value.replaceAll("[\t]", "' + char(9) +'");
		value = value.replaceAll("[\n]", "' + char(13) +'");
		
		return "'"+value+"'";
	}
	
}
